package com.szqhyxj.youxiangju.biz.onlineChannel;

import com.google.gson.annotations.SerializedName;
import com.szqhyxj.youxiangju.sys.BaseResult;
import com.szqhyxj.youxiangju.sys.RetrofitFacade;

import java.util.List;

import io.reactivex.Observable;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;

/**
 * XiaoPanYu
 * on 2018/11/26
 */
public class ChannelModel {


    public interface ChannelService {
        /**
         * 获取通道列表
         *
         * @param cardId
         * @param channelType
         * @return
         */
        @FormUrlEncoded
        @POST("online/channel/query")
        Observable<BaseResult<ChannelEntity>> getChannelList(
                @Field("cardId") String cardId,
                @Field("channelType") String channelType
        );


        /**
         * 申请绑卡
         *
         * @param cardId
         * @param channelId
         * @param frontUrl
         * @return
         */
        @FormUrlEncoded
        @POST("merchant/oper/bind")
        Observable<BaseResult<String>> getbindCard(
                @Field("cardId") String cardId,
                @Field("channelId") String channelId,
                @Field("frontUrl") String frontUrl
        );

        /**
         * 确定绑卡
         *
         * @param smsCode
         * @param cardId
         * @param channelId
         * @return
         */
        @FormUrlEncoded
        @POST("merchant/oper/confirm")
        Observable<BaseResult<String>> confirmBindCard(
                @Field("smsCode") String smsCode,
                @Field("cardId") String cardId,
                @Field("channelId") String channelId
        );

    }

    /**
     * 获取通道列表
     */
    public static Observable<BaseResult<ChannelEntity>> getChannelList(String cardId, String channelType) {
        return RetrofitFacade.Companion.getRetrofit().create(ChannelService.class).getChannelList(cardId, channelType);
    }


    /**
     * 申请绑卡
     *
     * @param cardId
     * @param channelId
     * @param frontUrl
     * @return
     */
    public static Observable<BaseResult<String>> getbindCard(String cardId, String channelId, String frontUrl) {
        return RetrofitFacade.Companion.getRetrofit().create(ChannelService.class).getbindCard(cardId, channelId, frontUrl);
    }

    //确定绑卡
    public static Observable<BaseResult<String>> confirmBindCard(String smsCode, String cardId, String channelId) {
        return RetrofitFacade.Companion.getRetrofit().create(ChannelService.class).confirmBindCard(smsCode, cardId, channelId);
    }


    public class ChannelEntity {

        @SerializedName("total")
        private int total;

        @SerializedName("rows")
        private List<RowsItem> rows;

        public void setTotal(int total) {
            this.total = total;
        }

        public int getTotal() {
            return total;
        }

        public void setRows(List<RowsItem> rows) {
            this.rows = rows;
        }

        public List<RowsItem> getRows() {
            return rows;
        }

        @Override
        public String toString() {
            return
                    "ChannelEntity{" +
                            "total = '" + total + '\'' +
                            ",rows = '" + rows + '\'' +
                            "}";
        }
    }

    public class RowsItem {

        @SerializedName("minAmount")
        private int minAmount;

        @SerializedName("fee")
        private String fee;

        @SerializedName("errMsg")
        private String errMsg;

        @SerializedName("topFee")
        private String topFee;

        @SerializedName("minPaymentAmount")
        private int minPaymentAmount;

        @SerializedName("channelName")
        private String channelName;

        @SerializedName("startTime")
        private int startTime;

        @SerializedName("fixedFee")
        private String fixedFee;

        @SerializedName("endTime")
        private int endTime;

        @SerializedName("authType")
        private int authType;

        @SerializedName("maxAmount")
        private int maxAmount;

        @SerializedName("maxPaymentAmount")
        private int maxPaymentAmount;

        @SerializedName("support")
        private int support;

        @SerializedName("channelId")
        private int channelId;

        @SerializedName("consumeType")
        private int consumeType;

        @SerializedName("bindStatus")
        private int bindStatus;

        public String getChannelCode() {
            return channelCode;
        }

        public void setChannelCode(String channelCode) {
            this.channelCode = channelCode;
        }

        @SerializedName("channelCode")
        private String channelCode;

        public void setMinAmount(int minAmount) {
            this.minAmount = minAmount;
        }

        public int getMinAmount() {
            return minAmount;
        }

        public void setFee(String fee) {
            this.fee = fee;
        }

        public String getFee() {
            return fee;
        }

        public void setErrMsg(String errMsg) {
            this.errMsg = errMsg;
        }

        public String getErrMsg() {
            return errMsg;
        }

        public void setTopFee(String topFee) {
            this.topFee = topFee;
        }

        public String getTopFee() {
            return topFee;
        }

        public void setMinPaymentAmount(int minPaymentAmount) {
            this.minPaymentAmount = minPaymentAmount;
        }

        public int getMinPaymentAmount() {
            return minPaymentAmount;
        }

        public void setChannelName(String channelName) {
            this.channelName = channelName;
        }

        public String getChannelName() {
            return channelName;
        }

        public void setStartTime(int startTime) {
            this.startTime = startTime;
        }

        public int getStartTime() {
            return startTime;
        }

        public void setFixedFee(String fixedFee) {
            this.fixedFee = fixedFee;
        }

        public String getFixedFee() {
            return fixedFee;
        }

        public void setEndTime(int endTime) {
            this.endTime = endTime;
        }

        public int getEndTime() {
            return endTime;
        }

        public void setAuthType(int authType) {
            this.authType = authType;
        }

        public int getAuthType() {
            return authType;
        }

        public void setMaxAmount(int maxAmount) {
            this.maxAmount = maxAmount;
        }

        public int getMaxAmount() {
            return maxAmount;
        }

        public void setMaxPaymentAmount(int maxPaymentAmount) {
            this.maxPaymentAmount = maxPaymentAmount;
        }

        public int getMaxPaymentAmount() {
            return maxPaymentAmount;
        }

        public void setSupport(int support) {
            this.support = support;
        }

        public int getSupport() {
            return support;
        }

        public void setChannelId(int channelId) {
            this.channelId = channelId;
        }

        public int getChannelId() {
            return channelId;
        }

        public void setConsumeType(int consumeType) {
            this.consumeType = consumeType;
        }

        public int getConsumeType() {
            return consumeType;
        }

        public void setBindStatus(int bindStatus) {
            this.bindStatus = bindStatus;
        }

        public int getBindStatus() {
            return bindStatus;
        }

        @Override
        public String toString() {
            return
                    "RowsItem{" +
                            "minAmount = '" + minAmount + '\'' +
                            ",fee = '" + fee + '\'' +
                            ",errMsg = '" + errMsg + '\'' +
                            ",topFee = '" + topFee + '\'' +
                            ",minPaymentAmount = '" + minPaymentAmount + '\'' +
                            ",channelName = '" + channelName + '\'' +
                            ",startTime = '" + startTime + '\'' +
                            ",fixedFee = '" + fixedFee + '\'' +
                            ",endTime = '" + endTime + '\'' +
                            ",authType = '" + authType + '\'' +
                            ",maxAmount = '" + maxAmount + '\'' +
                            ",maxPaymentAmount = '" + maxPaymentAmount + '\'' +
                            ",support = '" + support + '\'' +
                            ",channelId = '" + channelId + '\'' +
                            ",consumeType = '" + consumeType + '\'' +
                            ",bindStatus = '" + bindStatus + '\'' +
                            "}";
        }
    }
}
